package com.wangp.mywrite.coding;

import java.util.ArrayList;
import java.util.List;

class MyCalendar {

   List<int[]> booked;
   
    public MyCalendar() {
        booked = new ArrayList<>();
    }

    public boolean book(int start, int end) {
        for (int[] arr : booked) {
            int l = arr[0], r = arr[1];
            if (l < end && start < r) {
                return false;
            }
        }
        booked.add(new int[]{start, end});
        return true;
    }


    public static void main(String[] args) {
        MyCalendar myCalendar = new MyCalendar();
        boolean b1 = myCalendar.book(10, 20);
        boolean b2 = myCalendar.book(15,25);
        boolean b3 = myCalendar.book(20,30);
    }
}

/**
 * Your MyCalendar object will be instantiated and called as such:
 * MyCalendar obj = new MyCalendar();
 * boolean param_1 = obj.book(start,end);
 */